home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Online / Qpopper / popper.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-02  |  13.3 KB  |  383 lines

  1. /*
  2.  * Copyright (c) 1989 Regents of the University of California.
  3.  * All rights reserved.  The Berkeley software License Agreement
  4.  * specifies the terms and conditions for redistribution.
  5.  *
  6.  * static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
  7.  * static char SccsId[] = "@(#)@(#)popper.h    2.2  2.2 4/2/91";
  8.  *
  9.  */
  10.  
  11. /*  LINTLIBRARY */
  12.  
  13. /* 
  14.  *  Header file for the POP programs
  15.  */
  16.  
  17. #ifdef POPSCO
  18. # include <sys/syslog.h>
  19. #else
  20. # include <syslog.h>
  21. #endif
  22. #include <sys/socket.h>
  23. #include "version.h"
  24.  
  25. #ifdef ISC
  26. # include <sys/types.h>
  27. # include <sys/fcntl.h>
  28. # include <net/errno.h>
  29. #endif
  30.  
  31. #ifdef        HAVE_PARAM_H
  32. #include <sys/param.h>
  33. # if (defined(BSD) && (BSD >= 199103))
  34. #  define    HAVE_UNISTD_H
  35. #  define    HAVE_VSPRINTF
  36. #  define    BIND43
  37. # endif
  38. #endif
  39.  
  40. #ifdef BSDI
  41. #define BSD44_DBM
  42. #endif
  43.  
  44. #ifdef BULLDB
  45. # undef    DBM        /* used by mts.c and ndbm.h */
  46. # include <ndbm.h>
  47. #endif
  48.  
  49. #define NULLCP          ((char *) 0)
  50. #define SPACE           32
  51. #define TAB             9
  52. #define TRUE            1
  53. #define FALSE           0
  54. #define NEWLINE         '\n'
  55.  
  56. #define MAXUSERNAMELEN  65
  57. #define MAXDROPLEN      64
  58. #define MAXLINELEN      1024
  59. #define MAXMSGLINELEN   MAXLINELEN
  60. #define MAXCMDLEN       4
  61. #define MAXPARMCOUNT    5
  62. #define MAXPARMLEN      10
  63. #define ALLOC_MSGS  20
  64.  
  65. #ifndef OSF1
  66. # define POP_FACILITY    LOG_LOCAL0
  67. #else
  68. # define POP_FACILITY    LOG_MAIL
  69. #endif
  70. #define POP_PRIORITY    LOG_NOTICE
  71. #define POP_DEBUG       LOG_DEBUG
  72. #define POP_LOGOPTS     LOG_PID
  73.  
  74. #ifdef POPSCO
  75. # define L_SET  0
  76. # define L_XTND 2
  77. #endif
  78.  
  79.             /* ^A */
  80. #define    MMDF_SEP_CHAR    '\001'
  81.  
  82. /* For performance reasons large sites should change the pop tempdrop
  83.  * location to another directory other than the mail spool location.
  84.  * The more files referenced in a directory, the slower the access is
  85.  */
  86.  
  87. #if defined(OSF1) || defined(AIX)
  88. # define POP_MAILDIR     "/var/spool/mail"
  89. # define POP_DROP        POP_MAILDIR "/.%s.pop"
  90. # define POP_TMPDROP     POP_MAILDIR "/tmpXXXXXX"
  91. # define POP_TMPXMIT     POP_MAILDIR "/xmitXXXXXX"
  92. # define MAIL_COMMAND     "/usr/sbin/sendmail"
  93. # define OSDONE
  94. #endif
  95.  
  96. #ifdef AMIGA
  97. # define POP_MAILDIR     "/uumail"
  98. # define POP_DROP        "/uumail/.%s.pop"
  99. # define POP_TMPDROP     "/uumail/tmpXXXXXX"
  100. # define POP_TMPXMIT     "/uumail/xmitXXXXXX"
  101. # define MAIL_COMMAND     "/amitcp/bin/sendmail"
  102. # define OSDONE
  103. #endif
  104.  
  105. #if !defined(OSDONE) && defined(SYSV) && !defined(POPSCO) && !defined(LINUX)
  106. # define POP_MAILDIR     "/usr/mail"
  107. # define POP_DROP        "/usr/mail/.%s.pop"
  108. # define POP_TMPDROP     "/usr/mail/tmpXXXXXX"
  109. # if defined(AUX) || defined(AIX)
  110. #  define POP_TMPXMIT     "/tmp/xmitXXXXXX"
  111. # else
  112. #  define POP_TMPXMIT     "/usr/mail/xmitXXXXXX"
  113. # endif
  114. # define MAIL_COMMAND     "/usr/lib/sendmail"
  115. # define OSDONE
  116. #endif
  117.  
  118. #if !defined(OSDONE) && (defined(BSD) && ((BSD) >= 199103))
  119. # define POP_MAILDIR     "/var/mail"
  120. # define POP_DROP        "/var/mail/.%s.pop"
  121. # define POP_TMPDROP     "/var/mail/tmpXXXXXX"
  122. # define POP_TMPXMIT     "/var/mail/xmitXXXXXX"
  123. # define MAIL_COMMAND     "/usr/sbin/sendmail"
  124. # define OSDONE
  125. #endif
  126.  
  127. #ifndef OSDONE
  128. # define POP_MAILDIR     "/usr/spool/mail"
  129. # define POP_DROP        "/usr/spool/mail/.%s.pop"
  130. # define POP_TMPDROP     "/usr/spool/mail/tmpXXXXXX"
  131. # define POP_TMPXMIT     "/usr/spool/mail/xmitXXXXXX"
  132. # define MAIL_COMMAND     "/usr/lib/sendmail"
  133. #endif
  134.  
  135. /*
  136.  * The default string for HOMEDIRMAIL is "%s/.mail".  You need to change
  137.  * the value in pop_dropcopy.h in routine genpath() if you wish to modify
  138.  * the mail drop location.
  139.  */
  140.  
  141. /* Define his path to default the bulletin dir.
  142.  *    -DBULLDIR= "/usr/mail/bulletins"
  143.  * in the make file works well or you can define BULLDIR before the #ifdef.
  144.  */
  145.  
  146. #ifndef BULLDIR
  147. #define BULLDIR        NULL
  148. #endif
  149.  
  150.             /* Defines the minimum number of bulletins a new user
  151.                receives */
  152. #define NEWBULLCNT    1
  153.  
  154. #ifndef CONTENT_LENGTH
  155. #define CONTENT_LENGTH 0
  156. #endif
  157.  
  158. /* POP_TMPSIZE needs to be big enough to hold the string
  159.  * defined by POP_TMPDROP.  POP_DROP and POP_TMPDROP
  160.  * must be in the same filesystem.
  161.  */
  162. #define POP_TMPSIZE    256
  163. #define POP_OK          "+OK"
  164. #define POP_ERR         "-ERR"
  165. #define POP_SUCCESS     1
  166. #define POP_FAILURE     0
  167. #define POP_TERMINATE   '.'
  168. #define POP_TIMEOUT    120    /* timeout connection after this many secs */
  169.  
  170.             /* UID's <= this value are not allowed to access email */
  171. #define BLOCK_UID    10
  172.  
  173. #define DIG_SIZE    16
  174.  
  175.         /* Set these to the types your OS returns if they are not
  176.            already typedefed for you */
  177. #define OFF_T        off_t
  178. #define PID_T        pid_t
  179. #define UID_T        uid_t
  180. #define GID_T        gid_t
  181. #define    TIME_T        time_t
  182. #define SIZE_T        size_t
  183.  
  184. #ifdef NEXT
  185. #undef PID_T
  186. #define PID_T        int
  187. #endif
  188.  
  189. #ifdef CHECK_SHELL
  190. #define WILDCARD_SHELL    "/POPPER/ANY/SHELL/"
  191. #endif
  192.  
  193. extern int              errno;
  194.  
  195. #if !(defined(BSD) && (BSD >= 199306))
  196. extern int              sys_nerr;
  197. extern char         *   sys_errlist[];
  198. #if !defined(__linux__) && !defined(AMIGA)
  199. extern char         *   sys_siglist[];
  200. #endif
  201. #endif
  202.  
  203. extern int        pop_timeout;
  204.  
  205. extern int        hangup;
  206.  
  207. #define pop_command         pop_parm[0]     /*  POP command is first token */
  208. #define pop_subcommand      pop_parm[1]     /*  POP XTND subcommand is the 
  209.                                                 second token */
  210.  
  211. typedef enum {                              /*  POP processing states */
  212.     auth1,                                  /*  Authorization: waiting for 
  213.                                                 USER command */
  214.     auth2,                                  /*  Authorization: waiting for 
  215.                                                 PASS command */
  216.     trans,                                  /*  Transaction */
  217.     update,                                 /*  Update:  session ended, 
  218.                                                 process maildrop changes */
  219.     halt,                                   /*  (Halt):  stop processing 
  220.                                                 and exit */
  221.     error                                   /*  (Error): something really 
  222.                                                 bad happened */
  223. } state;
  224.  
  225. typedef struct {                                /*  State information for 
  226.                                                     each POP command */
  227.     state       ValidCurrentState;              /*  The operating state of 
  228.                                                     the command */
  229.     char   *    command;                        /*  The POP command */
  230.     int         min_parms;                      /*  Minimum number of parms 
  231.                                                     for the command */
  232.     int         max_parms;                      /*  Maximum number of parms 
  233.                                                     for the command */
  234.     int         (*function) ();                 /*  The function that process 
  235.                                                     the command */
  236.     state       result[2];                      /*  The resulting state after 
  237.                                                     command processing */
  238. #define success_state   result[0]               /*  State when a command 
  239.                                                     succeeds */
  240. } state_table;
  241.  
  242. typedef struct {                                /*  Table of extensions */
  243.     char   *    subcommand;                     /*  The POP XTND subcommand */
  244.     int         min_parms;                      /*  Minimum number of parms for
  245.                                                     the subcommand */
  246.     int         max_parms;                      /*  Maximum number of parms for
  247.                                                     the subcommand */
  248.     int         (*function) ();                 /*  The function that processes 
  249.                                                     the subcommand */
  250. } xtnd_table;
  251.  
  252. typedef struct {                                /*  Message information */
  253.     int         number;                         /*  Message number relative to 
  254.                                                     the beginning of list */
  255.     long        length;                         /*  Length of message in 
  256.                                                     bytes */
  257.     int         lines;                          /*  Number of (null-terminated)
  258.                             lines in the message */
  259.     int         body_lines;            /*  Number of (null-terminated)
  260.                                lines in the body */
  261.     long        offset;                         /*  Offset from beginning of 
  262.                                                     file */
  263.     int         del_flag;                       /*  Flag indicating if message 
  264.                                                     is marked for deletion */
  265.     int         retr_flag;                      /*  Flag indicating if message 
  266.                                                     was retrieved */
  267.     int        orig_retr_state;        /*  What was the state at the
  268.                             start of this session.
  269.                             Used for RSET cmd. */
  270.     char    *uidl_str;            /*  Cache of the UIDL str for
  271.                             faster access */
  272. } MsgInfoList;
  273.  
  274. typedef struct  {                               /*  POP parameter block */
  275.     int                 debug;                  /*  Debugging requested */
  276.     int                 stats;                  /*  Stats requested */
  277.     int            dirty;            /*  Any mailbox changes? */
  278.     int            kerberos;        /*  Flag to enable kerberos
  279.                             authentication */
  280.     int            server_mode;        /*  Default at compile time */
  281.     char            *   myname;                 /*  The name of this POP 
  282.                                                     daemon program */
  283.     char            *   myhost;                 /*  The name of our host 
  284.                                                     computer */
  285.     char            *   client;                 /*  Canonical name of client 
  286.                                                     computer */
  287.     char            *   ipaddr;                 /*  Dotted-notation format of 
  288.                                                     client IP address */
  289.     unsigned short      ipport;                 /*  Client port for privileged 
  290.                                                     operations */
  291.     char                user[MAXUSERNAMELEN];   /*  Name of the POP user */
  292.     state               CurrentState;           /*  The current POP operational                                                     state */
  293.     MsgInfoList     *   mlp;                    /*  Message information list */
  294.     int                 msg_count;              /*  Number of messages in 
  295.                                                     the maildrop */
  296.     int                 msgs_deleted;           /*  Number of messages flagged 
  297.                                                     for deletion */
  298.     int                 last_msg;               /*  Last message touched by 
  299.                                                     the user */
  300.     long                bytes_deleted;          /*  Number of maildrop bytes 
  301.                                                     flagged for deletion */
  302.     char                drop_name[MAXDROPLEN];  /*  The name of the user's 
  303.                                                     maildrop */
  304.     char                temp_drop[MAXDROPLEN];  /*  The name of the user's 
  305.                                                     temporary maildrop */
  306.     long                drop_size;              /*  Size of the maildrop in
  307.                                                     bytes */
  308.     long        spool_end;        /*  Offset of the end of the
  309.                             mailspool */
  310.     FILE            *   drop;                   /*  (Temporary) mail drop */
  311.     FILE            *   input;                  /*  Input TCP/IP communication 
  312.                                                     stream */
  313.     FILE            *   output;                 /*  Output TCP/IP communication                                                     stream */
  314.     FILE            *   trace;                  /*  Debugging trace file */
  315.     FILE            *   hold;                   /*  In SERVER_MODE, this value
  316.                             holds the drop FILE */
  317.     char            *   pop_parm[MAXPARMCOUNT]; /*  Parse POP parameter list */
  318.     int                 parm_count;             /*  Number of parameters in 
  319.                                                     parsed list */
  320.     char            *   bulldir;                /*  Bulletin directory */
  321. #ifdef BULLDB
  322.     DBM            *    bull_db;        /*  Central Bulletin Database */
  323. #endif
  324.     char        *    mmdf_separator;        /*  string between messages */
  325.     char        md5str[BUFSIZ];        /*  String used with the shared
  326.                             secret to create the md5
  327.                             digest */
  328. } POP;
  329.  
  330. #ifdef KERBEROS
  331.  
  332. #ifndef KERBEROS_SERVICE
  333. # define KERBEROS_SERVICE    "rcmd"
  334. #endif
  335.  
  336. #ifdef SOLARIS2
  337. # include <kerberos/krb.h>
  338. #else
  339. # ifdef BSDI
  340. #  include <kerberosIV/des.h>
  341. #  include <kerberosIV/krb.h>
  342. # else
  343. #  include <krb.h>
  344. # endif
  345. #endif
  346. extern AUTH_DAT kdata;
  347. #endif /* KERBEROS */
  348.  
  349. #if defined(AUTHFILE)
  350. extern int  checkauthfile();
  351. #endif
  352. #if defined(NONAUTHFILE)
  353. extern int  checknonauthfile();
  354. #endif
  355.  
  356. extern int  pop_dele();
  357. extern int  pop_last();
  358. extern int  pop_list();
  359. extern int  pop_pass();
  360. extern int  pop_rpop();
  361. extern int  pop_apop();
  362. extern int  pop_quit();
  363. extern int  pop_rset();
  364. extern int  pop_send();
  365. extern int  pop_stat();
  366. extern int  pop_updt();
  367. extern int  pop_user();
  368. extern int  pop_xtnd();
  369. extern int  pop_xmit();
  370. extern int  pop_xlst();
  371. extern int  pop_uidl();
  372. extern int  pop_euidl();
  373. extern int  isfromline();
  374. extern int  genpath();
  375.  
  376. extern char *pwerrmsg;
  377.  
  378. #define pop_auth_fail    pop_msg
  379. /*
  380. extern int  pop_auth_fail();
  381. */
  382.  
  383.